import CommonHeader from '@/components/CommonHeader'
import { IRouteComponentProps, useDispatch } from 'umi'
import {Layout} from 'antd'
import { useEffect } from 'react';

const whiteList = ['/', '/archives', '/knowledge']
export default function GlobalLayout({ children, location, route, history, match }: IRouteComponentProps) {
  let body = children;
  if (whiteList.indexOf(location.pathname) !== -1){
    body =  <div className="container content">
      {children}
    </div>
  }
  const dispatch = useDispatch();

  // 获取网站的全局配置
  useEffect(() => {
    dispatch({
      type: 'setting/getSetting'
    })
    dispatch({
      type: 'setting/getPageSetting'
    })
  }, [])
  return <Layout>
    <CommonHeader />
    {body}
  </Layout>
}
